home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_MakeMenu.c < prev    next >
C/C++ Source or Header  |  1996-03-18  |  1KB  |  59 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_MENUS
  15.  
  16.     /* LTP_MakeMenu(RootMenu *Root,MenuNode *Menu,struct NewMenu *Template):
  17.      *
  18.      *    Create a single menu and fill it in.
  19.      */
  20.  
  21. MenuNode *
  22. LTP_MakeMenu(RootMenu *Root,MenuNode *Menu,struct NewMenu *Template)
  23. {
  24.         // If none is provided, roll our own
  25.  
  26.     if(!Menu)
  27.         Menu = (MenuNode *)AsmAllocPooled(Root->Pool,sizeof(MenuNode),SysBase);
  28.  
  29.     if(Menu)
  30.     {
  31.         STRPTR Label = Template->nm_Label;
  32.  
  33.             // Use the screen font for the layout
  34.  
  35.         SetFont(&Root->RPort,Root->DrawInfo->dri_Font);
  36.  
  37.             // Fill in the size
  38.  
  39.         Menu->Menu.Width    = TextLength(&Root->RPort,Label,strlen(Label)) + 6;
  40.         Menu->Menu.Height    = Root->Screen->BarHeight;
  41.  
  42.         Menu->Menu.MenuName    = (BYTE *)Label;
  43.         Menu->UserData        = Template->nm_UserData;
  44.  
  45.             // Return to the original font
  46.  
  47.         SetFont(&Root->RPort,Root->Font);
  48.  
  49.             // Take care of the only valid bit
  50.  
  51.         if(!(Template->nm_Flags & NM_MENUDISABLED))
  52.             Menu->Menu.Flags = MENUENABLED;
  53.     }
  54.  
  55.     return(Menu);
  56. }
  57.  
  58. #endif    /* DO_MENUS */
  59.